// 定义和医院设置相关的发送请求的函数
import { Key } from 'react'
import { request } from '@utils/http'

// 引入接口
import {
  IhospitalSetRes,
  IhospitalSetParams,
  IhospitalSetItem,
} from './model/hospitalSetTypes'

// 获取医院设置的表格数据
export function reqHospitalSets(
  page: number,
  limit: number,
  hosname?: string,
  hoscode?: string
) {
  // 给axios方法传入泛型, 是为了告诉ts,响应回来的数据是什么类型的
  return request.get<any, IhospitalSetRes>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  )
}

// 添加医院设置的函数
export function reqAddHospitalSet(data: IhospitalSetParams) {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, data)
}

// 获取一条医院设置数据的函数
export function reqGetHospitalSet(id: string) {
  return request.get<any, IhospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`)
}
// 修改一条医院设置的数据
export function reqUpdateHospitalSet(data: IhospitalSetParams) {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, data)
}
// 删除一条医院设置的数据
export function reqDelHospitalSet(id: string) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}
// 批量删除医院设置的数据
export function reqBatchDelHospitalSet(ids: Key[]) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids,
  })
}
